package com.sx.gongzhong.pest;

import com.sx.gongzhong.model.DefendRoadBean;
import com.sx.gongzhong.model.HeadParamBean;
import com.sx.gongzhong.model.ReplyUserBean;
import com.sx.gongzhong.net.ApiManager;
import com.sx.gongzhong.net.BaseCallBack;
import com.sx.gongzhong.model.BasePageListBean;
import com.sx.gongzhong.view.IDefendRoadListView;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by XZY on 2018/1/9.
 * 全民护路的列表
 */

public class DefendRoadListPest {

    private IDefendRoadListView listView;

    public DefendRoadListPest(IDefendRoadListView listView) {
        this.listView = listView;
    }

    /**
     * @param page 页
     * @param rows 条数
     */
    public void loadDefendRoadList(int page ,int rows ){
        Map<String,Object> map= new HashMap<>();
        map.put("sourcesState",0);
        map.put("page", page);
        map.put("rows", rows);

        new ApiManager().loadDefendRoadList(map, new BaseCallBack<ReplyUserBean.BaseResult<BasePageListBean<DefendRoadBean>>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<BasePageListBean<DefendRoadBean>> response) {
                listView.loadDefendRoadList(response.getData().rows,response.data.records);
            }

            @Override
            public void onFailures(String message) {
                listView.showError(message);
            }
        });
    }
    /**
     *我的全民护路列表
     */
    public void myDefendRoadList(int page ,int rows ){
        Map<String,Object> map = HeadParamBean.getHead();
        map.put("page", page);
        map.put("rows", rows);

        new ApiManager().myDefendRoadList(map, new BaseCallBack<ReplyUserBean.BaseResult<BasePageListBean<DefendRoadBean>>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<BasePageListBean<DefendRoadBean>> response) {
                listView.loadDefendRoadList(response.getData().rows,response.data.records);
            }

            @Override
            public void onFailures(String message) {
                listView.showError(message);
            }
        });

    }
}
